using System;
using NUnit.Framework;

namespace NUnit.Behave.Specs.BehavioralFixture_Specs
{
    [TestFixture]
    [Category("BehavioralFixture_Specs")]
    public class When_calling_the_Given_method_with_a_message_and_value : BehavioralFixture
    {
        [SetUp]
        public void SetUpContext()
        {
            base.SetUpFixture();
            Given("my wagon is the color", "Red");
        }

        [Test]
        public void I_am_now()
        {
        }

    }

    [TestFixture]
    [Category("BehavioralFixture_Specs")]
    public class When_calling_the_Story_method_with_a_message_Then : BehavioralFixture
    {
        [SetUp]
        public void SetUpContext()
        {
            base.SetUpFixture();
            Story("Account Holder withdraws cash")
                .As_a("savings account holder")
                .I_Want("to transfer money from my savings account")
                .So_That("I can get cash easily from an ATM");
        }

        [Test]
        public void Should_add_message_to_message_heap_as()
        {
            string expected = "Story: Account Holder withdraws cash\r\n" +
                              "Nerative: As a savings account holder \r\n\t" +
                              "I want to transfer money from my savings account \r\n\t" +
                              "so that I can get cash easily from an ATM.\r\n";

            Assert.AreEqual(expected, messageHeap.ToString());
        }

        [Test]
        public void Should_not_be_able_to_call_Given_method_with_out_a_story_being_present()
        {
            Assert.Ignore("Add exception for calling given out of context");
        }
    }

    [TestFixture]
    [Category("BehavioralFixture_Specs")]
    public class When_you_have_a_complete_story_and_you_add_a_scenario : BehavioralFixture
    {
        [SetUp]
        public void SetUpContext()
        {
            base.SetUpFixture();
            Story("Account Holder withdraws cash")
                .As_a("savings account holder")
                .I_Want("to transfer money from my savings account")
                .So_That("I can get cash easily from an ATM")
                .Scenario("savings account is overdrawn")
                .Given("my savings account balance is", -20)
                .And("my cash account balance is", 10)
                .When("I transfer to cash account", 20)
                .Then("my savings account balance should be", -20)
                .And("my cash account balance should be", "Strong");
        }

        [Test]
        public void Should_add_message_to_message_heap_as()
        {
            string expected = "Story: Account Holder withdraws cash\r\n" +
                              "Nerative: As a savings account holder \r\n\t" +
                              "I want to transfer money from my savings account \r\n\t" +
                              "so that I can get cash easily from an ATM.\r\n";

            Assert.IsTrue(messageHeap.ToString().Contains(expected));
        }

        [Test]
        public void Should_not_be_able_to_call_Given_method_with_out_a_story_being_present()
        {
            Assert.Ignore("Add exception for calling given out of context");
        }
    }

    [TestFixture]
    [Category("BehavioralFixture_Specs")]
    public class When_calling_the_Given_method_and_using_a_Given_conjunction : BehavioralFixture
    {
        private string givenExpected = "Given my wagon is the color: Red !PENDING Delegate IMPLEMENTATION!";
        private string givenConjunctionExpected = "And the wagon wheels are type: 10 !PENDING Delegate IMPLEMENTATION!";


        [SetUp]
        public void SetUpContext()
        {
            base.SetUpFixture();
            Given("my wagon is the color", "Red").And("the wagon wheels are type", 10);
        }


        [Test]
        public void Should_add_the_following_messages_to_message_heap_pending()
        {
            Assert.IsTrue(messageHeap.ToString().Contains(givenExpected));

            Assert.IsTrue(messageHeap.ToString().Contains(givenConjunctionExpected));
        }
    }
}